package com.iplant.mes.service.po.exc;

import com.fasterxml.jackson.annotation.JsonProperty;
import com.iplant.base.po.BasePO;
import com.iplant.base.po.enums.DBSchemas;
import com.iplant.base.utils.annotation.condition.DBCondition;
import com.iplant.base.utils.annotation.field.DBField;
import com.iplant.base.utils.annotation.join.DBJoin;
import com.iplant.base.utils.annotation.join.multi.DBJoinMulti;
import com.iplant.base.utils.annotation.po.DBBasePO;
import com.iplant.base.utils.general.CalendarTool;
import com.iplant.mes.service.mesenum.exc.EXCLineStopStatus;
import lombok.extern.slf4j.Slf4j;

import java.util.ArrayList;
import java.util.Calendar;
import java.util.List;

/**
 * 停线 停序
 */
@Slf4j
@DBBasePO(TableName = "exc_line_stop", Schemas = DBSchemas.MES, Name = false, Active = false,
        CheckName = {"Code"}, CodeAuto = true, CodePrefix = "LSR-{yyMM}-", CodeNum = 4)
public class EXCLineStop extends BasePO {

    /**
     * 订单ID
     */
    @DBCondition
    @DBField
    public int OrderID = 0;
    /**
     * 订单号
     */
    @DBCondition
    @DBField
    public String OrderNo = "";

    @DBCondition
    @DBField
    public int ProductID = 0;

    @DBJoin(name = "Code", tableName = "fpc_product", tableAsName = "fpc_product1", Schemas = DBSchemas.PDM,
            MainTableField = "ProductID")
    public String ProductNo = "";

    @DBJoin(name = "Name", tableName = "fpc_product", tableAsName = "fpc_product1", Schemas = DBSchemas.PDM,
            MainTableField = "ProductID")
    public String ProductName = "";


    /**
     * 停线停序开始日期
     */
    @DBCondition(CompareType = DBCondition.DBCompareType.geLe, ParamName = "StartDate", ParamName2 = "EndDate")
    @DBField
    public Calendar StopStartDate = CalendarTool.getDate();

    /**
     * 预计停线停序完成日期
     */
    @DBField
    public Calendar PlanEndDate = CalendarTool.getDate();

    /**
     * 停序确认人
     */
    @DBCondition
    @DBField
    public int ConfirmedID = 0;

    @DBJoinMulti(Name = "Name", TableName = "mbs_user", Schemas = DBSchemas.Basic, MainTableField =
            "ConfirmedID")
    public String ConfirmedName = "";

    /**
     * 停序关闭人
     */
    @DBCondition
    @DBField
    public int CancelPersonID = 0;

    @DBJoinMulti(Name = "Name", TableName = "mbs_user", Schemas = DBSchemas.Basic, MainTableField =
            "CancelPersonID")
    public String CancelPersonName = "";

    /**
     * 停线停序完成日期
     */
    @DBField
    public Calendar StopEndDate = CalendarTool.getDate();

    /**
     * 停序停线状态 1保存  2停线中  3已撤销 4已完成
     */
    @DBCondition
    @DBField
    public int Status = 0;

    /**
     * 停序停线状态文本
     */
    public String StatusText = "";

    /**
     * 停序/停线执行备注  Description 单据描述
     */
    @DBField
    public String Remark = "";

    /**
     * 规则明细  一个规则明细内部只能包含一个序列号
     */
    @DBField(DefaultValue = "'[]'", CheckValue = true, isJson = true)
    public List<EXCPartPoint> PartPointList = new ArrayList<>();

    /**
     * 是否显示停线停序原因
     */
    @DBCondition
    @DBField
    public int IsShowMessage = 0;

    @JsonProperty("OrderID")
    public int getOrderID() {
        return OrderID;
    }

    public void setOrderID(int orderID) {
        OrderID = orderID;
    }

    @JsonProperty("OrderNo")
    public String getOrderNo() {
        return OrderNo;
    }

    public void setOrderNo(String orderNo) {
        OrderNo = orderNo;
    }

    @JsonProperty("ProductID")
    public int getProductID() {
        return ProductID;
    }

    public void setProductID(int productID) {
        ProductID = productID;
    }

    @JsonProperty("ProductNo")
    public String getProductNo() {
        return ProductNo;
    }

    public void setProductNo(String productNo) {
        ProductNo = productNo;
    }

    @JsonProperty("ProductName")
    public String getProductName() {
        return ProductName;
    }

    public void setProductName(String productName) {
        ProductName = productName;
    }


    @JsonProperty("StopStartDate")
    public Calendar getStopStartDate() {
        return StopStartDate;
    }

    public void setStopStartDate(Calendar stopStartDate) {
        StopStartDate = stopStartDate;
    }

    @JsonProperty("PlanEndDate")
    public Calendar getPlanEndDate() {
        return PlanEndDate;
    }

    public void setPlanEndDate(Calendar planEndDate) {
        PlanEndDate = planEndDate;
    }

    @JsonProperty("ConfirmedID")
    public int getConfirmedID() {
        return ConfirmedID;
    }

    public void setConfirmedID(int confirmedID) {
        ConfirmedID = confirmedID;
    }

    @JsonProperty("ConfirmedName")
    public String getConfirmedName() {
        return ConfirmedName;
    }

    public void setConfirmedName(String confirmedName) {
        ConfirmedName = confirmedName;
    }

    @JsonProperty("CancelPersonID")
    public int getCancelPersonID() {
        return CancelPersonID;
    }

    public void setCancelPersonID(int cancelPersonID) {
        CancelPersonID = cancelPersonID;
    }

    @JsonProperty("CancelPersonName")
    public String getCancelPersonName() {
        return CancelPersonName;
    }

    public void setCancelPersonName(String cancelPersonName) {
        CancelPersonName = cancelPersonName;
    }

    @JsonProperty("StopEndDate")
    public Calendar getStopEndDate() {
        return StopEndDate;
    }

    public void setStopEndDate(Calendar stopEndDate) {
        StopEndDate = stopEndDate;
    }

    @JsonProperty("Status")
    public int getStatus() {
        return Status;
    }

    public void setStatus(int status) {
        Status = status;
    }

    @JsonProperty("Remark")
    public String getRemark() {
        return Remark;
    }

    public void setRemark(String remark) {
        Remark = remark;
    }

    @JsonProperty("PartPointList")
    public List<EXCPartPoint> getPartPointList() {
        return PartPointList;
    }

    public void setPartPointList(List<EXCPartPoint> partPointList) {
        PartPointList = partPointList;
    }

    @JsonProperty("StatusText")
    public String getStatusText() {
        StatusText = EXCLineStopStatus.getEnumType(Status).getLabel();
        return StatusText;
    }

    public void setStatusText(String statusText) {
        StatusText = statusText;
    }

    @JsonProperty("IsShowMessage")
    public int getIsShowMessage() {
        return IsShowMessage;
    }

    public void setIsShowMessage(int isShowMessage) {
        IsShowMessage = isShowMessage;
    }
}
